﻿using Core.Configuration.Utils;
using Core.Sdk.WeiXin.Domain;
using Core.Sdk.WeiXin.Domain.Map;
using System;

namespace Core.Sdk.WeiXin
{
    public class MapSdk
    {
        /// <summary>
        ///  获取IP定位信息
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public static async Task<IpResult> GetIpLocation(string ip)
        {
            var url = $"https://apis.map.qq.com/ws/location/v1/ip?key={MapConfig.Key}&ip={ip}";
            var result = await HttpHelper.GetAsync<MapResult<IpResult>>(url);
            //查询成功
            if (result.status == 0)
                return result.result;
            return new IpResult();
        }
    }
}
